//
//  NSString+AttrString.m
//  XZLife
//
//  Created by Liangshangjia on 15/9/2.
//  Copyright (c) 2015年 Sami-industry. All rights reserved.
//

#import "NSString+Attributed.h"
@implementation NSString (Attributed)

- (NSAttributedString *)attributedStringWithColor:(UIColor *)color andFont:(UIFont *)font andLineSpacing:(CGFloat)lineSpacing
{
    
    NSMutableParagraphStyle * lineStyle = [[NSMutableParagraphStyle alloc] init];
    [lineStyle setLineSpacing:lineSpacing];
    
    NSMutableDictionary *attributeDict = [NSMutableDictionary dictionaryWithCapacity:3];
    if (color) {
        [attributeDict setObject:color forKey:NSForegroundColorAttributeName];
    }
    if (font) {
        [attributeDict setObject:font forKey:NSFontAttributeName];
    }
    [attributeDict setObject:lineStyle forKey:NSParagraphStyleAttributeName];
    
    return [[NSAttributedString alloc]initWithString:self attributes:attributeDict];
}


- (NSAttributedString *)attributedStringWithLineSpacing:(CGFloat)lineSpacing
{
   return [self attributedStringWithColor:nil andFont:nil andLineSpacing:lineSpacing];
}
@end
